var slideAfter = 15000;
var runSlider = true;
var windowWidth;
var carusselHeight = 400;
var carusselMinHeight = 135;

$(document).ready(function(e) {
windowWidth = $(window).width();
	var items = $("#carussel-wrapper div");
	jQuery.each(items, function() {
		$(this).css("width", windowWidth);
	});
	
	setTimeout(slideCarussel, slideAfter);
});

//slideCarussel().delay(2000);	

$(window).resize(function() {
	windowWidth = $(window).width();
	var items = $("#carussel-wrapper div");
	jQuery.each(items, function() {
		$(this).css("width", windowWidth);
	});
});

function carusselSlideDown() {
	$('#carussel').animate({
		height: carusselHeight
	}, 1000);
}

function carusselSlideUp() {
	$('#carussel').animate({
		height: carusselMinHeight
	}, 1000);
}

function slideCarussel() {
	$("#carussel-wrapper").animate({
		left: '-='+windowWidth
	}, 2000, slideFinished );	
}

function slideFinished() {
	$("#carussel-wrapper div:last").after($("#carussel-wrapper div:first"));
	$("#carussel-wrapper").css("left",0);

	if(runSlider) {
		setTimeout(slideCarussel, slideAfter);
	}
}

function carusselHide() {
	$("#carussel").hide();	
}

function carusselShow() {
	$("#carussel").show();	
}


function closeCarussel() {
	$("#carussel").slideUp(1000);
}

function openCarussel() {
	$("#carussel").slideDown(1000);
}